package com.snake.springboot.authority.service.assembler;

import com.snake.springboot.authority.api.model.AuthStrategyModel;
import com.snake.springboot.authority.dao.mybatis.entity.AuthStrategyDO;
import org.snake.common.code.SerialNumberGeneratorFactory;
import org.snake.common.utils.PropertyUtils;

/**
 * 类 {@code AuthStrategyAssmbler}  <br> .
 * <p>权限策略组装器
 * <p>创建时间：2025/02/07
 *
 * @author Huang.yj
 */
public class AuthStrategyAssembler {

    public static AuthStrategyDO assembleAuthStrategyDO(AuthStrategyModel model, boolean isNew) throws Exception {
        AuthStrategyDO entity = new AuthStrategyDO();
        PropertyUtils.copyPropertiesIfNull(entity, model);
        if (isNew) {
            SerialNumberGeneratorFactory.buildId4Bean(entity, "strategyId");
        }
        return entity;
    }

    public static AuthStrategyModel assembleAuthStrategyModel(AuthStrategyDO entity) {
        AuthStrategyModel model = new AuthStrategyModel();
        PropertyUtils.copyPropertiesIfNull(model, entity);
        return model;
    }

}
